//
// Created by shenbin on 2022/6/3.
// https://leetcode.cn/problems/find-peak-element/
//

#ifndef ALGORITHM_TRAINNING_C03_LC162_H
#define ALGORITHM_TRAINNING_C03_LC162_H

#include <vector>

using namespace std;

class LeetCode162 {
public:
    int findPeakElement(vector<int> &nums) {
        int left = 0, right = nums.size() - 1;
        while (left < right) {
            int lmid = (left + right) / 2;
            int rmid = lmid + 1;
            if (nums[lmid] <= nums[rmid])
                left = lmid + 1;
            else
                right = lmid - 1;
        }
        return right;
    }
};

#endif //ALGORITHM_TRAINNING_C03_LC162_H
